const connection = require('../app/database')
class UserService {
  /** 创建用户 */
  async createUser (user) {
    // 获取user对象
    const { name, password } = user
    // 创建sql语句
    const ps = 'INSERT INTO `user` ( NAME, PASSWORD ) VALUES ( ?,? )'
    // 执行sql
    const [result] = await connection.execute(ps, [name, password])
    return result
  }
  /** 查询用户 */
  async findUser(name){
    const ps='SELECT * FROM `user` WHERE NAME = ( ? )'
    const [result]=await connection.execute(ps,[name])
    return result
  }
}
module.exports = new UserService()